package com.flea.hclv.controller;

import com.flea.hclv.service.HCarVisitorService;
import com.flea.hclv.util.ServerResponse;
import com.flea.system.platform.session.FleaOrgUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * @program: project
 * @description: 游客选座
 * @author: shiliqiang
 * @create: 2019-01-02 11:13
 * @version: 1.0
 */
@Controller
@RequestMapping("/flea/hclv/car/visitor/")
public class HCarVisitorController {

    @Autowired
    private HCarVisitorService hCarVisitorService;

    //创建座位并返回所有座位
    @RequestMapping("createCarSeat")
    @ResponseBody
    public ServerResponse<Map<String, Object>> createCarSeat(HttpServletRequest request, String timeTableId){
        String userId = FleaOrgUtils.getCurUserUuid(request);
        ServerResponse<Map<String, Object>> response = hCarVisitorService.createCarSeat(userId,timeTableId);
        return response;
    }
    //根据班期Id所有座位
    @RequestMapping("selectByTimeTableId")
    @ResponseBody
    public ServerResponse<Map<String,Object>> selectByTimeTableId(HttpServletRequest request, String timeTableId){
        String userId = FleaOrgUtils.getCurUserUuid(request);
        ServerResponse<Map<String,Object>> response = hCarVisitorService.selectByTimeTableId(userId,timeTableId,null);
        return response;
    }
    //选座位
    @RequestMapping("selectSeatNumber")
    @ResponseBody
    public ServerResponse<String> selectSeatNumber(HttpServletRequest request,String model) throws Exception {
        String userId = FleaOrgUtils.getCurUserUuid(request);
        ServerResponse<String> response = hCarVisitorService.saveSeatNumber(userId,model);
        return response;
    }
    //根据班期导出游客和座位号
    @RequestMapping("exportVisitorSeats")
    @ResponseBody
    public ServerResponse<String> exportVisitorSeats(HttpServletRequest request, String timeTableId, HttpServletResponse response) throws Exception {
        ServerResponse<String> response1 = hCarVisitorService.selectExportVisitorSeats(timeTableId,response);
        return response1;
    }

    //取消座位
//    @RequestMapping("cancelSeatNumber")
//    @ResponseBody
//    public ServerResponse<String> cancelSeatNumber(HttpServletRequest request,St) throws Exception {
//        String userId = FleaOrgUtils.getCurUserUuid(request);
//        ServerResponse<String> response = hCarVisitorService.saveSeatNumber(userId,model);
//        return response;
//    }

}
